import request from "@/request/request"
import requestMock from "@/request/requestMock"


//封装请求三级分类列表请求
export const reqCategoryList = () => {
    return request.get("/product/getBaseCategoryList")
}

//封装请求banner数据的
export const reqGetBannerList = () => {
    return requestMock.get("banner/list")
}

//封装请求floor数据的
export const reqGetFloorList = () => {
    return requestMock.get("floor/list")
}

//封装请求商品列表信息
export const reqSearchList = (params) => {
    // console.log(params);
    return request.post("/list", params)
}

// 封装请求商品详情信息的请求
export const reqGoodsDetail = (skuId) => {
    return request.get(`/item/${ skuId }`)
}

// 封装添加商品到购物车的请求
export const reqAddGoodsToCart = (skuId, skuNum) => {
    return request.post(`/cart/addToCart/${ skuId }/${ skuNum }`)
}

// 封装购物车初始化数据的请求
export const reqGoodsCartList = () => {
    return request.get(`/cart/cartList`)
}

// 修改购物车单个商品的选中状态
export const reqCheckCart = (skuID, isChecked) => {
    return request.get(`/cart/checkCart/${skuID}/${isChecked}`)
}

// 删除购物车单个商品
export const reqDeleteCart = (skuId) => {
    return request.delete(`/cart/deleteCart/${skuId}`)
}

// 修改购物车全部商品的选中状态
export const reqAllCheckCart = (skuIdList, isChecked) => {
    return request.post(`/cart/batchCheckCart/${isChecked}`, skuIdList)
}

// 批量删除选中的商品
export const reqDeleteAll = (skuIdList) => {
    return request.delete(`/cart/batchDeleteCart`, {
        data: skuIdList
    })
}

// 获取验证码
export const reqGetAuthCode = (phone) => {
    return request.get(`/user/passport/sendCode/${phone}`)
}

// 注册请求
export const reqUserRegister = (userInfo) => {
    return request.post(`/user/passport/register`, userInfo)
}

// 登录请求
export const reqUserLogin = (userInfo) => {
    return request.post(`/user/passport/login`, userInfo)
}

// 获取用户信息
export const reqUserInfo = () => {
    return request.get(`/user/passport/auth/getUserInfo`)
}

// 退出登录
export const reqLogout = () => {
    return request.get(`/user/passport/logout`)
}

// 获取收获人地址
export const reqUserAddress = () => {
    return requestMock.get(`/userAddress/list`)
}

// 获取订单交易页面信息
export const reqTradeInfo = () => {
    return request.get(`/order/auth/trade`)
}

// 获取提交订单
export const reqSubmitTrade = (tradeNo, orderInfo) => {
    // console.log(tradeNo, orderInfo);
    return request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, orderInfo)
}

//  获取支付详情
export const reqPayInfo = (orderId) => {
    return request.get(`/payment/weixin/createNative/${orderId}`)
}

// 查询支付订单状态
export const reqPayStatus = (orderId) => {
    return request.get(`/payment/weixin/queryPayStatus/${orderId}`)
}

//查询订单列表
export const reqMyOrderList = (page, limit) => {
    return request.get(`/order/auth/${page}/${limit}`)
}